package com.pshcp.patient.tool;

import com.framework.tool.CommonTool;
import com.pshcp.common.tool.PhotoTools;
import com.pshcp.domain.model.Doctor;
import com.pshcp.domain.model.OrderReg;
import com.pshcp.domain.model.PatientOnlineOrder;
import com.pshcp.patient.domain.home.vo.ActiveDoctorVO;
import com.pshcp.patient.domain.home.vo.ActiveOnlineOrderVO;
import com.pshcp.patient.domain.home.vo.ActiveOrderVO;
import com.pshcp.patient.domain.home.vo.ActiveRegOrderVO;

import java.util.ArrayList;
import java.util.List;

public class PatientHomeTools {

    public static void buildActiveOnline(ActiveOrderVO activeOrderVO, List<PatientOnlineOrder> activeOnlineOrder){
        ActiveOnlineOrderVO onlineOrderVO = new ActiveOnlineOrderVO();
        onlineOrderVO.setOnlineOrderId(activeOnlineOrder.get(0).getId());
        onlineOrderVO.setDesc(String.format("您有%d笔进行中的问诊订单",activeOnlineOrder.size()));
        activeOrderVO.setActiveOnlineOrderVO(onlineOrderVO);
    }

    public static void buildActiveDoctor(ActiveOrderVO activeOrderVO, Doctor doctor, boolean isFavor, String prefixPath){
        ActiveDoctorVO doctorVO = CommonTool.copyProperties(doctor, ActiveDoctorVO.class);
        doctorVO.setOnline(true);
        // 是否关注医生
        doctorVO.setFavor(isFavor);
        doctorVO.setFullHeadPhotoPath(PhotoTools.getFullPath(prefixPath, doctorVO.getHeadPhoto()));
        List<ActiveDoctorVO> voList = new ArrayList<>();
        voList.add(doctorVO);
        activeOrderVO.setActiveDoctorVOS(voList);
    }

    public static void buildActiveRegOrder(ActiveOrderVO activeOrderVO, List<OrderReg> orderRegs){
        List<ActiveRegOrderVO> regOrderVOS = new ArrayList<>();
        orderRegs.forEach(or -> {
            ActiveRegOrderVO regOrderVO = CommonTool.copyProperties(or, ActiveRegOrderVO.class);
            regOrderVOS.add(regOrderVO);
        });
        activeOrderVO.setActiveRegOrderVOS(regOrderVOS);
    }

}
